function number(form_telephone) {
	var nb1 = document.getElementById(form_telephone);
	if (isNaN(document.inscription.form_telephone.value)) {
		alert('this is not a number ');
	}
}

function myValueChanged(labeltochagecolor, referencedivtwo) {

	if (document.getElementById(labeltochagecolor).value == document
			.getElementById(referencedivtwo).value) {
		document.getElementById(labeltochagecolor).style.backgroundColor = 'blue';
	} else {
		document.getElementById(labeltochagecolor).style.backgroundColor = 'red';
	}
}

function selectonchange() {
	if (document.inscription.elements['profession'].options[document.inscription.elements['profession'].selectedIndex].value == "professeur") {
		document.getElementById('formspecialite').style.display = 'block';
		document.getElementById('formfiliere').style.display = 'none';
		document.getElementById('formanne').style.display = 'none';

	} else {
		document.getElementById('formspecialite').style.display = 'none';
		document.getElementById('formfiliere').style.display = 'block';
		document.getElementById('formanne').style.display = 'block';

	}

}
function modifchang() {
	if (document.inscription.login.value == ('')
			|| document.inscription.inputpassword.value == ('')
			|| document.inscription.inputconfirmationpassword.value == ('')
			|| document.inscription.email.value == ('')
			|| document.inscription.inputconfirmationpassword.value == ('')
			|| document.inscription.email.value == ('')
			|| document.inscription.profession.value == ('')
			|| document.inscription.day.value == ('')
			|| document.inscription.lastname.value == ('')
			|| document.inscription.firstname.value == (''))
		alert('veuillez remplir les zones vides');
	else
		document.inscription.submit();
}
function afficher(xml) {
	$(".canbedeleted").remove();
	var htmlcontent = "";
	$(xml).find('cour').each(function() {
		var id = $(this).attr('id');
		var val = $(this).attr('val');
		htmlcontent += "<option value='" + id + "'>" + val + "</option>";
	});
	var links = "";
	$(xml).find('file').each(
			function() {
				var idfile = $(this).attr('id');
				var nomfile = $(this).attr('nom');
				var path = $(this).attr('href');
				links += "<div id='cour" + idfile + "'><a  href='" + path
						+ "'>" + nomfile + "</a> <a onclick='deletecours("
						+ idfile
						+ ");' href='javascript:void(0);' >Delete </a></div>";
			});
	$("#cours").html(htmlcontent);
	$("#cours").show();
	$("#filecours").html("");
	$("#filecours").append(links);
}
function feedback(xml) {
	// $(".canbedeleted").remove();
	var htmlcontent = "";
	$(xml).find('feedback').each(function() {
		var feedback = $(this).attr('val');
		htmlcontent += "<div class='feedback'>" + feedback + "</div>";
	});
	$("#feedback").html(htmlcontent);
}
function updatecours(id_categorie) {
	$.ajax({
		type : "POST",
		dataType : "xml",
		url : "/pigierwebsite/xmlfile.php",
		data : "updatecours=" + 1 + "&categorie=" + id_categorie ,
		success : function(data) {
			afficheCategories(data,2);
		}
	});
}
function updateCategries(filiere, annee) {
	$.ajax({
		type : "POST",
		dataType : "xml",
		url : "/pigierwebsite/categoriesxml.php",
		data : "updatecours=" + 1 + "&filiere=" + filiere + "&annee=" + annee,
		success : function(data) {
			afficheCategories(data,1);
		}
	});
}
function updateinputforcour(){
	
	htmlcontent = "<option value='0'> Pas de cours </option>";
	$("#cours").html(htmlcontent);
	htmlcontent = "<option value='0'> Pas de categories </option>";
	$("#scategories").html(htmlcontent);
	$("#annee").val(0).attr('selected',true);
}
function afficheCategories(xml,ff) {
	//$(".canbedeleted").remove();
	var htmlcontent = "";
	var showornot=0;
	$(xml).find('categories').each(function() {
		var id = $(this).attr('id');
		var val = $(this).attr('val');
		htmlcontent += "<option value='" + id + "'>" + val + "</option>";
		showornot=1;
	});
	if (showornot==0 && ff!=2) {
		htmlcontent = "<option value='0'> Pas de categories </option>";
	}
	if (ff!=2) {
		$("#scategories").html(htmlcontent);
		$("#categories").show();
	}
	
	showornot=0;
	htmlcontent = "";
	$(xml).find('cour').each(function() {
		var id = $(this).attr('id');
		var val = $(this).attr('val');
		htmlcontent += "<option value='" + id + "'>" + val + "</option>";
		showornot=1;
	});
	if (showornot==0) {
		htmlcontent = "<option value='0'> Pas de cours </option>";
	}
	$("#cours").html(htmlcontent);
	$("#forcours").show();
	
	showornot=0;
	htmlcontent = "";
	links="si";
	$(xml).find('file').each(
			function() {
				var idfile = $(this).attr('id');
				var nomfile = $(this).attr('nom');
				var path = $(this).attr('href');
				links += "<div id='cour" + idfile + "'><a  href='" + path
						+ "'>" + nomfile + "</a> <a onclick='deletecours("
						+ idfile
						+ ");' href='javascript:void(0);' >Delete </a></div>";
				showornot=1;
			});
	
	if (showornot!=0) {
	$("#filecours").html(links);
	//$("#filecours").show();
	}
	
}
function deletecours($idcour) {
	$.ajax({
		type : "POST",
		dataType : "xml",
		url : "/pigierwebsite/deletecours.php",
		data : "cours=" + 1 + "&delete=" + $idcour,
		success : function(data) {
			feedback(data);
			$('#cour' + $idcour).remove();
		}
	});
}
